<%@codepage="65001"%>
<%session.codepage="65001"%>
<!-- #include virtual=/inc/dbConn.asp -->
<!-- #include virtual=/inc/function.asp -->
<!-- #include virtual=/inc/action.header.inc.asp -->

<%
	'## 파라미터 변수 선언부			
	company		= Request("company")
	major			= Request("major")
	majorPhone	= Request("majorPhone")
	majorEmail	= Request("majorEmail")
	projectNm		= Request("projectNm")
	totalAmount	= Request("totalAmount")
	totalTax		= Request("totalTax")
	remark			= Request("remark")
	estCd			= Request("estCd")
	flag				= Request("flag")

	If totalAmount = "" Then totalAmount = "0" End If 
	If totalTax = "" Then totalTax = "0" End If 

	major				= Replace(major,"'","''")
	majorPhone		= Replace(majorPhone,"'","''")
	majorEmail		= Replace(majorEmail,"'","''")
	remark				= Replace(remark,"'","''")
	projectNm			= Replace(projectNm,"'","''")
	totalAmount		= Replace(totalAmount,",","")
	totalTax			= Replace(totalTax,",","")
	totalPrice			= Cdbl(totalAmount)+Cdbl(totalTax)
	
	issueId = Request.Cookies("S_uid")
	
	If estCd = "" Then
		curMnth = mid(date(),3,6)
		curMnth = replace(curMnth,"-","")
		estCnt = aFieldValue("SELECT ISNULL(COUNT(*),0)+1 FROM tblEstimate WHERE estCd LIKE 'NT_E_" & curMnth & "%'")
		If len(estCnt) = 1 Then 
			estCd = "NT_E_" & curMnth & "000" & estCnt
		ElseIf len(estCnt) = 2 Then 
			estCd = "NT_E_" & curMnth & "00" & estCnt
		ElseIf len(estCnt) = 3 Then 
			estCd = "NT_E_" & curMnth & "0" & estCnt
		Else
			estCd = "NT_E_" & curMnth & estCnt
		End If
	End If
	
	SQLTitle = "-- ■■■■ 견적서 정보 관리 저장 ■■■■"
	SQL = "exec spEstimate '" & company & "', '" & major & "', '" & majorPhone & "', '" & majorEmail & "', '" & projectNm & "', " & totalPrice & ", " & totalTax & ", " & totalAmount & ", '" & remark & "', '" & issueId & "', '" & flag & "', '" & estCd & "'"
	
	If xMode="debug" Then 
		Call showDebug(SQLTitle,SQL) 
	End If 

'Response.write SQL
'Response.end
	DbCon.Execute SQL

	Call rsWithXML2("Save OK!",estCd)
%>